package com.tpc.yaoxpt;


import javafx.application.Application;
import javafx.event.EventHandler;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.stage.Stage;

import javafx.stage.WindowEvent;

import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;

import java.io.IOException;
import java.lang.reflect.InvocationTargetException;


//@SpringBootApplication(exclude={DataSourceAutoConfiguration.class})
//public class YaoxptApplication extends AbstractJavaFxApplicationSupport {
//    public static Stage stage;
//
//    @Override
//    public void start(Stage primaryStage) throws Exception {
//        stage = primaryStage;
//        Parent root = FXMLLoader.load(getClass().getResource("/fxml/main.fxml"));
//        stage.setScene(new Scene(root));
//        stage.setWidth(950);
//        stage.setHeight(680);
//        stage.setTitle("药械平台--解决方案");
//        stage.getIcons().add(new Image(getClass().getResourceAsStream("/ico/e5.png")));
//        stage.setResizable(false);
//        stage.centerOnScreen();
//        stage.show();
//
//        stage.setOnCloseRequest(new EventHandler<WindowEvent>() {
//            @Override
//            public void handle(WindowEvent event) {
//                // 执行一些自定义操作
//                System.out.println("应用程序关闭中！！！");
//                System.exit(0);
//            }
//        });
//    }
//
//    public static void main(String[] args) {
//        //启动(若需要以fxml形式展示主界面,则第二个传参可以为"MainStageView.class"之类的)
//        launch(args);
//    }
//}

@SpringBootApplication
public class YaoxptApplication extends Application {
    @Override
    public void start(Stage stage)  {
        try {
            FXMLLoader loader = new FXMLLoader(getClass().getResource("/fxml/main.fxml"));
            Parent root = loader.load();
            stage.getIcons().add(new Image(getClass().getResourceAsStream("/ico/e5.png")));
            Scene scene = new Scene(root, 950, 680);
            stage.setTitle("药械平台--解决方案");
            stage.setScene(scene);
            stage.show();
            stage.setOnCloseRequest(new EventHandler<WindowEvent>() {
                @Override
                public void handle(WindowEvent event) {
                    // 执行一些自定义操作
                    System.out.println("应用程序关闭中！！！");
                    System.exit(0);
                }
            });
        }catch (IOException e){
            Throwable actualException = e.getCause();
            actualException.printStackTrace();
        }
    }

    public static void main(String[] args) {
        launch(YaoxptApplication.class, args);
    }
}